{template header}
<div class="divColor regDivColor">
  <ul class="app_register">
    <li class="purpleColor">1.填写信息</li>
    <li>2.验证信息</li>
    <li>3.重置密码</li>
  </ul>
  <style type="text/css">
  .errmsg{ text-align:center; color:red; line-height:30px;}
  </style>
  <?php if($_GET["step"]==""){?>
  <form action="{U('User/Public/repwd')}" method="post" class="repwdform" >
    <input type="hidden" name="step" value="1" />
    <div class="zhucefor errmsg" id="win"> </div>
    <div class="app_login">
      <input type="text" name="account" id="account" class="forgetuser" placeholder="请输入手机号码" datatype="m" errormsg="手机号码格式不正确" nullmsg='手机号码格式不正确' >
      <p class="p3"></p>
    </div>
    <div class="app_loginYZM">
     <input type="text" name="userverify" id="userverify" class="code" placeholder="请输入验证码" maxlength="8"  datatype="*" errormsg="请输入验证码" nullmsg='请输入验证码' >
        &nbsp;&nbsp;<a href="javascript:void(0);" class="codeimg"><img src="<?php echo U('verify') ?>" id="verify" alt="看不清楚，换一张" style="cursor: pointer; width:80px;" onclick="this.src='<?php echo U('verify') ?>&_t=' + Math.round(new Date().getTime()/1000)" /></a>
    </div>
    <div class="app_loginSub">
      <input type="submit" value="下一步" />
    </div>
  </form>
  <?php
  }
  ?>
  <?php if($_GET["step"]==2){?>
   <form action="{U('User/Public/repwdstep')}" method="post" class="hlgbut_box">
    <input type="hidden" name="step" value="3" />
               		<input type="hidden" name="re_info" id="re_info" value="{$_SESSION['re_info']}" />
                    <input type="hidden" name="re_type" id="re_type" value="{$_SESSION['re_type']}" />
    <div class="zhucefor errmsg" id="win"> </div>
    <div class="app_login">
      验证码已发送至&nbsp;&nbsp;<i>{$_SESSION['re_info']}</i> 的<?php if($_SESSION["re_type"]=="mobile_phone"){echo '手机'; }else{echo "邮箱";}?>
    </div>
    <style type="text/css">
	.hqcode{ background:#f55151; color:#fff; padding:10px 10px; margin-left:10px; float:left}
	</style>
    <div class="app_loginYZM">
     <input type="text" name="userverify" id="userverify" class="sjcode" placeholder="请输入验证码" maxlength="8"><a href="javascript:void(0);" class="shuaxincode send_code hqcode">免费获取验证码</a>
    </div>
    <div class="app_loginSub">
      <input type="button" class="hlgbut" value="下一步" />
    </div>
  </form>
  <script type="text/javascript">
				$(function(){
					$(".hlgbut").click(function(){
						var code=$("#userverify").val();
						if(code==""){
							$(".errmsg").text("验证码不能为空").show();
							return false;	
						}
						$(".hlgbut_box").submit();
					})	
				})
				</script>
  <?php
  }
  ?>
  
  <?php if($_GET["step"]==3){?>
 <form action="{U('User/Public/repwdstep')}" method="post" class="hlgbut_box">
    <input type="hidden" name="step" value="4" />
               		<input type="hidden" name="re_info" id="re_info" value="{$_POST['re_info']}" />
                    <input type="hidden" name="re_type" id="re_type" value="{$_POST['re_type']}" />
    <div class="zhucefor errmsg" id="win"> </div>
    <div class="app_login">
         <input type="password"  datatype="pinpass" errormsg="密码范围在6~15位之间！" name="password" id="password" nullmsg='请填写密码' placeholder="请输入密码" class="zcpass">
        <p class="p2"></p>
    </div>
    <div class="app_login">
        <input type="password" name="userpassword2" datatype="*" recheck="password" errormsg="您两次输入的账号密码不一致！" nullmsg='请确认密码' placeholder="请再次确认密码" class="runpass">
        <p class="p2"></p>
    </div>
    <div class="app_loginSub">
   		<input type="button" class="hlgbut" value="立即重置" />
    </div>
  </form>
  <script type="text/javascript">
				$(function() {
					$(".hlgbut").click(function(){
						$(".hlgbut_box").submit();	
					})
					$(".hlgbut_box").Validform({
						tiptype:function(msg,o,cssctl){
								if(o.type==3){
									$(".errmsg").text(msg).show();
									return false;
								}
								if(o.type==1){
									o.obj.addClass("Validform_success")
								}
						},
						datatype:{
							"pinpass": function( gets , obj , curform , regxp ){
								 var reg1=/^[^\s]{6,15}$/;
								 if(!reg1.test(gets)){
									return "登录密码范围在6~15位之间";
								 }  
							}
						},
						ajaxPost: true,
						callback: function(ret) {
							if(ret.status == 0){
								$("#verify").click();
								$("#userverify").val("");	
							}
							if (ret.status ==1) {
								window.location="{U('User/Public/login')}"
							}
						}
					});
				})
				</script>
  <?php
  }
  ?>
</div>
<script type="text/javascript">				
$(function(){
    $(".send_code").click(function(){
        var text=$(this).text();
        var type=$(this).attr("type");
        if(text!="免费获取验证码"){
            return false;
        }
		var re_info=$("#re_info").val();
		var re_type=$("#re_type").val();
		$.ajax({url: "{U('User/Public/rew_send_code')}&re_type="+re_type+"&re_info="+re_info,timeout: 5000,cache: false,type: "get",async : false,dataType: "json",success: function (d) {
			if(d.status==1){
				 downtime(120);	
			}
			alert(d.info);
		}});
    })

})
function downtime(time){

//循环调用

if(time == '0'){

$('.send_code').text('免费获取验证码');

}else{

time --;

$('.send_code').text('重新发送（'+time+'）');

setTimeout(function() {

downtime(time);

},1000);} 

}
			</script>
<script type="text/javascript">
$(function() {
	$(".next").click(function(){
		$(".repwdform").submit();	
	})
	$(".repwdform").Validform({
		tiptype:function(msg,o,cssctl){
				if(o.type==3){
					$(".errmsg").text(msg).show();
					return false;
				}
				if(o.type==1){
					o.obj.addClass("Validform_success")
				}
			},
		ajaxPost: true,
		callback: function(ret) {
			if(ret.status == 1){
				$("#verify").click();
				$("#userverify").val("");	
			}
			if (ret.status < 2) {
				$(".errmsg").text(ret.info).show();
			} else {
				window.location="{U('User/Public/repwdstep',array('step'=>2))}"
			}
		}
	});
})
</script> 
{template /common/footer}